/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author damfercer
 */
@Entity
@Table(name = "company_product")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CompanyProduct.findAll", query = "SELECT c FROM CompanyProduct c"),
    @NamedQuery(name = "CompanyProduct.findByIdCompanyProduct", query = "SELECT c FROM CompanyProduct c WHERE c.idCompanyProduct = :idCompanyProduct"),
    @NamedQuery(name = "CompanyProduct.findByDescription", query = "SELECT c FROM CompanyProduct c WHERE c.description = :description"),
    @NamedQuery(name = "CompanyProduct.findByBasePrice", query = "SELECT c FROM CompanyProduct c WHERE c.basePrice = :basePrice"),
    @NamedQuery(name = "CompanyProduct.findByCurrentPrice", query = "SELECT c FROM CompanyProduct c WHERE c.currentPrice = :currentPrice"),
    @NamedQuery(name = "CompanyProduct.findByCredits", query = "SELECT c FROM CompanyProduct c WHERE c.credits = :credits")})
public class CompanyProduct implements Serializable {
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "companyProduct")
    private List<CompanyOrder> companyOrderList;
    @Basic(optional = false)
    @NotNull
    @Column(name = "CURRENT_PRICE")
    private BigDecimal currentPrice;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_COMPANY_PRODUCT")
    private Integer idCompanyProduct;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 40)
    @Column(name = "DESCRIPTION")
    private String description;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Column(name = "BASE_PRICE")
    private BigDecimal basePrice;
    @Basic(optional = false)
    @NotNull
    @Column(name = "CREDITS")
    private int credits;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "companyProduct", fetch = FetchType.LAZY)
    private List<CompanyAdquiredProduct> companyAdquiredProductList;

    public CompanyProduct() {
    }

    public CompanyProduct(Integer idCompanyProduct) {
        this.idCompanyProduct = idCompanyProduct;
    }

    public CompanyProduct(Integer idCompanyProduct, String description, BigDecimal basePrice, BigDecimal currentPrice, int credits) {
        this.idCompanyProduct = idCompanyProduct;
        this.description = description;
        this.basePrice = basePrice;
        this.currentPrice = currentPrice;
        this.credits = credits;
    }

    public Integer getIdCompanyProduct() {
        return idCompanyProduct;
    }

    public void setIdCompanyProduct(Integer idCompanyProduct) {
        this.idCompanyProduct = idCompanyProduct;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public BigDecimal getBasePrice() {
        return basePrice;
    }

    public void setBasePrice(BigDecimal basePrice) {
        this.basePrice = basePrice;
    }

    public BigDecimal getCurrentPrice() {
        return currentPrice;
    }

    public void setCurrentPrice(BigDecimal currentPrice) {
        this.currentPrice = currentPrice;
    }

    public int getCredits() {
        return credits;
    }

    public void setCredits(int credits) {
        this.credits = credits;
    }

    @XmlTransient
    public List<CompanyAdquiredProduct> getCompanyAdquiredProductList() {
        return companyAdquiredProductList;
    }

    public void setCompanyAdquiredProductList(List<CompanyAdquiredProduct> companyAdquiredProductList) {
        this.companyAdquiredProductList = companyAdquiredProductList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCompanyProduct != null ? idCompanyProduct.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CompanyProduct)) {
            return false;
        }
        CompanyProduct other = (CompanyProduct) object;
        if ((this.idCompanyProduct == null && other.idCompanyProduct != null) || (this.idCompanyProduct != null && !this.idCompanyProduct.equals(other.idCompanyProduct))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.CompanyProduct[ idCompanyProduct=" + idCompanyProduct + " ]";
    }

    @XmlTransient
    public List<CompanyOrder> getCompanyOrderList() {
        return companyOrderList;
    }

    public void setCompanyOrderList(List<CompanyOrder> companyOrderList) {
        this.companyOrderList = companyOrderList;
    }
    
}
